<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ProductCategory extends CI_Controller {
	
	public function index(){
		$this->cismarty->assign('baseUrl',$this->config->item('base_url'));
		$this->load->model('Product');
		$categoryList=$this->Product->getCategoryList();
		$this->cismarty->assign('categoryList',$categoryList);
		$this->cismarty->display('product/category.tpl');
	}

	public function create(){
		$this->load->model('Product');
		$arr=array('title'=>$_POST['title']);
		$this->Product->createCategory($arr);
		self::index();
	}
	
	public function createInit(){
		$this->cismarty->assign('baseUrl',$this->config->item('base_url')); 
		$this->cismarty->display('product/createCategory.tpl');
	}
	
	public function delete(){
		$this->load->model('Product');
		$id=$_GET['id'];
		$this->Product->deleteCategoryInfoById($id);
		self::index();
	}
	
	public function update(){
			$this->load->model('Product');
			$arr=array('title'=>$_POST['title']);
			$id=$_POST['id'];
			$this->Product->updateCategoryInfo($id,$arr);
			self::index();
	}
	
	public function updateInit(){
			$this->load->model('Product');
			$categoryInfo=$this->Product->getCategoryInfoById($_GET['id']);
			$this->cismarty->assign('categoryInfo',$categoryInfo);
			
			$this->cismarty->assign('baseUrl',$this->config->item('base_url')); 
			$this->cismarty->display('product/updateCategory.tpl');
	}

}
	

